const KerwinToken = artifacts.require('KerwinToken.sol')
const exchange = artifacts.require('Exchange.sol')
const ETHER_ADDRESS="0x0000000000000000000000000000000000000000"
const fromWei =(bn)=>{
    return web3.utils.fromWei(bn, 'ether');
}
const toWei = (number)=>{
    return web3.utils.toWei(number.toString(), 'ether');
}
module.exports = async function(callback) {
    const Kerwintoken = await KerwinToken.deployed()
    const Exchanges = await exchange.deployed()
    const accounts = await web3.eth.getAccounts()
    //无需授权
    // await Kerwintoken.approve(exchange.address, toWei(10000),{from:accounts[0]})
    await Exchanges.withdrawEther(toWei(5),{
        from:accounts[0]
    })
    let res = await Exchanges.tokens(ETHER_ADDRESS,accounts[0])
    console.log("减少->交易所->以太币余额",fromWei(res))

    await Exchanges.withdrawToken(Kerwintoken.address,toWei(10),{
        from:accounts[0]
    })
    let res1 = await Exchanges.tokens(Kerwintoken.address,accounts[0])
    console.log("减少->交易所->KWT币余额",fromWei(res1))
    callback()
}